package com.itcrowd.ittao.utils;

import android.content.Context;
import android.text.TextUtils;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.NetworkImageView;
import com.android.volley.toolbox.Volley;

public class ImageManager {
	
	private static RequestQueue sRequestQueue;
	private static ImageLoader sLoader;

	private ImageManager() {
	}
	
	public static void init(Context context) {
		sRequestQueue = Volley.newRequestQueue(context.getApplicationContext());
		sLoader = new ImageLoader(sRequestQueue, new BitmapCache());
	}
	
	public static void setImageUrl(NetworkImageView view, int defaultRes, String url) {
		view.setDefaultImageResId(defaultRes);
		if(!TextUtils.isEmpty(url)) {
			view.setImageUrl(url, sLoader);
		}
	}

}
